package com.sinosoft.tcmemr.webservice.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.sinosoft.framework.core.common.utils.StringUtil;
import com.sinosoft.tcmemr.service.DoctorUserService;
import com.sinosoft.tcmemr.webservice.TCMEMRWebService;
import com.sinosoft.tcmemr.webservice.dto.Request;
import com.sinosoft.tcmemr.webservice.dto.Response;

public class TCMEMRWebServiceImpl implements TCMEMRWebService {
	@Autowired
	private DoctorUserService doctoruserService;
	
	public DoctorUserService getDoctoruserService() {
		return doctoruserService;
	}

	public void setDoctoruserService(DoctorUserService doctoruserService) {
		this.doctoruserService = doctoruserService;
	}
	
	
	/**
	 * 增加医生用户信息
	 * @param request 请求参数
	 * @return  
	 */
	public String TCMEMR_addDoctorUsers(String request){
		Request r = new Request(request);
		if(StringUtil.isBlank(r.getRequsetParamValue("aid").toString())) {
			return new Response(r, "TCMEMR_addDoctorUsers服务调用失败：应用编号不能为空").toXmlString();
		}
		return new Response(r, "<dict><name>dict_gender</name><item>男</item><item>女</item></dict>").toXmlString();
	}
	
	public String sayHello(String request){
		
		return "lhztestHello:" + request;
	}
	

	/**
	 * 登录用户校验
	 * @param aid	应用编号
	 * @param username	用户账号
	 * @param password	密码原文
	 * @return	true/false
	 * @throws ObjectIsNotExistedException	对象不存在异常
	 */
	/*public ResponseData LoginUserCheckService(String username, 
			String password, String aid) throws ObjectIsNotExistedException{
		if(StringUtil.isBlank(aid)){
			return new ResponseData(false, null, "参数：应用编号不能为空", null);
		}
		if(StringUtil.isBlank(username)){
			return new ResponseData(false, null, "参数：用户名不能为空", null);
		}
		if(StringUtil.isBlank(password)){
			return new ResponseData(false, null, "参数：密码不能为空", null);
		}
		boolean result = doctoruserService.checkUserPassword(aid, username, password);
		return new ResponseData(result,null); 
	}*/
	
	/**
	 * 增加用户信息
	 * @param aid 应用编号
	 * @param username 用户账号
	 * @param password  密码原文
	 * @param doctorUserList 用户信息
	 * @return  true/false
	 */
	/*public ResponseData addDoctorUsersService(String aid, String username,
			String password, List<DoctorUserEntity> doctorUserList)
					throws ObjectIsNotExistedException{
		if(StringUtil.isBlank(aid)){
			return new ResponseData(false, null, "参数：应用编号不能为空", null);
		}
		if(StringUtil.isBlank(username)){
			return new ResponseData(false, null, "参数：用户名不能为空", null);
		}
		if(StringUtil.isBlank(password)){
			return new ResponseData(false, null, "参数：密码不能为空", null);
		}
		if(doctorUserList == null || doctorUserList.size() == 0 ){
			return new ResponseData(false, null, "参数：医生信息不能为空", null);
		}
		boolean result = doctoruserService.checkUserPassword(aid, username, password);
		if(result==false) {
			return new ResponseData(false, null, "用户名密码不匹配", null);
		}
		for(int i=0;i < doctorUserList.size();i++){
			doctoruserService.addDoctorUser(doctorUserList.get(i));
		}
		return new ResponseData(true,null); 
	}*/
	
	/**
	 * 获取医生用户信息
	 * @param aid 应用编号
	 * @param username 用户账号
	 * @param password  密码原文
	 * @return
	 */
	/*public ResponseData getDoctorUserService(String aid, String username,
			String password){
		if(StringUtil.isBlank(aid)){
			return new ResponseData(false, null, "参数：应用编号不能为空", null);
		}
		if(StringUtil.isBlank(username)){
			return new ResponseData(false, null, "参数：用户名不能为空", null);
		}
		if(StringUtil.isBlank(password)){
			return new ResponseData(false, null, "参数：密码不能为空", null);
		}
		DoctorUserEntity doctoruser = doctoruserService.getDoctorByUserName(username);
		
		return new ResponseData(true,doctoruser); 
	}*/
	
	
}
